// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './components/main.vue'
import VueRoute from 'vue-router'
import Routers from './router'
import store from "./store";
import "./css/common.scss"
import "./css/common.scss"
import "./css/reset.css"
import "../theme/index.css"
// import 'bootstrap/dist/css/bootstrap.min.css'
// import 'bootstrap/dist/js/bootstrap.min.js'
import promise from 'es6-promise'
import './util/rem';
import 'es6-promise/auto'
import 'babel-polyfill';
import VueProgressBar from 'vue-progressbar'
import { Message, MessageBox, Select,Option } from 'element-ui';
import Ajax from "@api/ajax"
promise.polyfill()

// 据说兼容ie6
function setCookie(a, b) {
  var d = new Date();
  var v = arguments;
  var c = arguments.length;
  var e = (c > 2) ? v[2] : null;
  var p = (c > 3) ? v[3] : null;
  var m = (c > 4) ? v[4] : window.location.host;
  var r = (c > 5) ? v[5] : false;
  if (e != null) {
    var T = parseFloat(e);
    var U = e.replace(T, "");
    T = (isNaN(T) || T <= 0) ? 1 : T;
    U = ("snhdwmqy".indexOf(U) == -1 || U == "") ? 's' : U.toLowerCase();
    switch (U) {
      case 's':
        d.setSeconds(d.getSeconds() + T);
        break;
      case 'n':
        d.setMinutes(d.getMinutes() + T);
        break;
      case 'h':
        d.setHours(d.getHours() + T);
        break;
      case 'd':
        d.setDate(d.getDate() + T);
        break;
      case 'w':
        d.setDate(d.getDate() + 7 * T);
        break;
      case 'm':
        d.setMonth(d.getMonth() + 1 + T);
        break;
      case 'q':
        d.setMonth(d.getMonth() + 1 + 3 * T);
        break;
      case 'y':
        d.setFullYear(d.getFullYear() + T);
        break
    }
  }
  let content = (a + "=" + escape(b)) + ((e == null) ? "" : ("; expires=" + d.toGMTString())) + ((p == null) ? ("; path=/") : ("; path=" + p)) + ("; domain=" + m) + ((r == true) ? "; secure" : "");
  document.cookie = `${content}`;
}
 function getCookieVal(name) {
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
    if(arr= document.cookie.match(reg))
        return unescape(arr[2]); 
    else 
        return null; 
}
function getCookie(a) {
  var v = a + "=";
  var i = 0;
  while (i < document.cookie.length) {
    var j = i + v.length;
    if (document.cookie.substring(i, j) == v) return getCookieVal(j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break
  }
  return null
}
function delCookie(a) {
  var e = new Date();
  e.setTime(e.getTime() - 1);
  var b = getCookie(a);
  document.cookie = a + "=" + a + ";path=/; domain=" + window.location.host + "; expires=" + e.toGMTString()
}


if (Number.parseInt === undefined) Number.parseInt = window.parseInt;
if (Number.parseFloat === undefined) Number.parseFloat = window.parseFloat;

const options = {
  color: '#7e57c2',
  failedColor: '#874b4b',
  thickness: '5px',
  transition: {
    speed: '0.2s',
    opacity: '0.6s',
    termination: 300
  },
  autoRevert: true,
  location: 'top',
  inverse: false
}
localStorage.ajaxTimeLock = true;
Vue.prototype.$ajax = Ajax;
Vue.prototype.$message = Message;
Vue.prototype.$confirm = MessageBox.confirm;
Vue.use(Select);
Vue.use(Option);
Vue.use(VueRoute);
Vue.use(VueProgressBar, options)
const Router = new VueRoute({
  mode: 'history', //process.env.NODE_ENV == "development" ?'history':'history', //history 线上
  routes: Routers
});
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router: Router,
  store,
  render: h => h(App)
})
